-
Notifications
You must be signed in to change notification settings - Fork 0
eng-557 build centralized linting system for all repos #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eng-557 build centralized linting system for all repos #10
Conversation
…t config file for new linter version
…tra export for matrixaiPlugin in index.ts
…rserOptions from config and creating new typeaware specific recommended configs
[ci skip]
… it into the normal recommended ruleset
… run eslint with a config override based inside the package when the lint script is run by a downstream repo when it is imported
…e they dont work and will need to be implemented later
…use their include folder to determine what patterns of folders to lint
Let's get this merged after fixing those minor things, and then integrate into js-logger as a start. |
Request @tegefaulkes to review once you are finished cleaning up this codebase in relation to conventions. Make sure to review js-logger as a template for how you should structure things, finish up the above reviews accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically functioning as a CLI program wrapping all our needs right?
We should consider using Commander
to handle the arg parsing and logic. That said its a bit much to address right now so we can make a new issue for tracking it.
console.error( | ||
`--config points to “${explicitConfigPath}”, but that file does not exist.`, | ||
); | ||
process.exit(1); // Hard‑fail; nothing to lint against | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we need to use a similar error structure to Polykey. This works but I'd rather have an explicit error that gets thrown and the message/exit code is handled automatically. That would be part of a Commander
conversion if we do it.
src/utils/utils.ts
Outdated
|
||
const cfg = rawCfg as { tsconfigPaths?: unknown; forceInclude?: unknown }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this, You're throwing type checking out of the window. It's also kinda pointless? You're saying an arbitray JSON object May have these keys and they are unknown? That's already true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is is a json file with an expected format then we need proper validation. Polykey already uses https://www.npmjs.com/package/ajv
to apply schema to it's status file. We can use the same thing here.
This may be another add on issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this, You're throwing type checking out of the window. It's also kinda pointless? You're saying an arbitray JSON object May have these keys and they are unknown? That's already true.
I've changed this to use a partial type with RawMatrixCfg:
type RawMatrixCfg = Partial<{
tsconfigPaths: unknown;
forceInclude: unknown;
}>;
and then casting it to this type with the asRawMatrixCfg
method:
function asRawMatrixCfg(v: unknown): RawMatrixCfg | undefined {
return typeof v === 'object' && v !== null ? (v as RawMatrixCfg) : undefined;
}
as a basic type guard. I think this will fix this issue in the short term but I'll keep this open in case we want a proper issue with the proper validation fix.
…self and removed the default eslint.config.mjs since its not needed anymore
…aving an invalid config json hard fail instead of falling back and removed unnecessary arrow functions
fixed potential race condition as well as eslint exiting the process prematurely if any error was found, preventing shellcheck or prettier from running
… and removed unnecessary interface. removed ignoring files console log
…orresponding file
… removed the main index.ts since nothing from there is being exported anymore. made a seperate plugin folder for the matrixai eslint plugin that contains our custom rules
Description
This PR will implement a centralized linting system which will allow all MatrixAI repos to import from a single linting package (this one) and apply appropriate linting rules without further intervention. It should also allow downstream repos to extend the system in order to ignore certain rules or add project-specific rules.
Issues Fixed
Tasks
🔧 Repository Refactor
js-eslint
tojs-lint
package.json
:@matrixai/lint
bin
entry:🧰 Lint Command Implementation
src/bin/lint.ts
zeta.house/scripts/lint.mjs
eslint
for JS/TS filesprettier
for markdownshellcheck
for shell scripts[ ] 5.4clang-format
for C/C++[ ] 5.5nixfmt
for Nix files[ ] 5.6rustfmt
for Rust filescommandExists
utility🧪 Add Utility Function
commandExists(programName: string): boolean
that:true
/false
for command existence📦 Package Dependencies
eslint
,@typescript-eslint
,prettier
, and related dependencieszeta.house
package.json
as a baselineshellcheck
orclang-format
inpackage.json
🔁 Plugin De-emphasis
🚀 Prepare for Release
v0.0.1
(CI will handle publishing)🌱 Downstream Integration
js-logger
@matrixai/lint
and verify it runs correctlyFinal checklist